<?php

namespace App\Http\Controllers\Api\User;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use App\Facades\Utils\ValidateParameter;
use App\Facades\Services\User\UserService;

class UserController extends Controller
{
    public function addUserInfo(Request $request){

        $rules = [
            'name' => 'required',
            'phone' => 'required',
            'weight' => 'required|numeric',
            'height' => 'required|numeric',
            'bmi' => 'required|numeric',
            'dis_age' => 'numeric'
        ];

        ValidateParameter::validate($request,$rules);

        $data= $request->all();

        UserService::addUserInfo($data);

        return formatJsonResponse();
    }

    public function updateUserInfo(Request $request){
        
        $rules = [
            'id' => 'required|exists:wechat_user_infos,id',
            'name' => 'required',
            'phone' => 'required',
            'weight' => 'required|numeric',
            'height' => 'required|numeric',
            'bmi' => 'required|numeric',
            'dis_age' => 'numeric'
        ];

        ValidateParameter::validate($request,$rules);

        $data= $request->all();

        UserService::updateUserInfo($data);

        return formatJsonResponse();
    }
}
